<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<%@ page import="org.codehaus.groovy.grails.commons.ConfigurationHolder" %>
<%@ page import="net.tribal.comic.entities.User" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <title><g:message code="user.create" default="CREATE USER" /></title>
    </head>
    <body>
    	
	        <div class="nav">
	            <span class="menuButton"><g:link class="list" action="list"><g:message code="user.list" default="USER LIST" /></g:link></span>
	        </div>
            <h1><g:message code="user.create" default="CREATE USER" /></h1>
            <g:if test="${flash.message}">
            	<div class="message"><g:message code="${flash.message}" args="${flash.args}" default="${flash.defaultMessage}" /></div>
            </g:if>
            <g:hasErrors bean="${userInstance}">
	            <div class="errors">
	                <g:renderErrors bean="${userInstance}" as="list" />
	            </div>
            </g:hasErrors>
            <g:uploadForm action="save">
                <div class="dialog roundedCorners wrapper">
                    <table>
                        <tbody>
                 	        <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="alias"><g:message code="user.alias" default="ALIAS" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'alias', 'errors')}">
                                    <g:textField id="alias" name="alias" value="${fieldValue(bean: userInstance, field: 'alias')}" class="focus"/>
                                </td>
                                <td valign="top" class="name">
                                    <label for="birdDay"><g:message code="user.birdDay" default="BIRD DAY" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'birdDay', 'errors')}">
                                    <g:datePicker name="birdDay" value="${userInstance?.birdDay}" precision="day"/>
                                </td>
                            </tr>
                            
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="name"><g:message code="user.name" default="NAME" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'name', 'errors')}">
                                    <g:textField name="name" value="${fieldValue(bean: userInstance, field: 'name')}" />
                                </td>
                                <td valign="top" class="name">
                                    <label for="country"><g:message code="user.country" default="COUNTRY" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'country', 'errors')}">
	                                <g:countrySelect name="country" default="esp" value="${fieldValue(bean:userInstance,field:'country')}"/>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="lastName"><g:message code="user.lastName" default="LAST NAME" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'lastName', 'errors')}">
                                    <g:textField name="lastName" value="${fieldValue(bean: userInstance, field: 'lastName')}" />
                                </td>
                                <td valign="top" class="name">
                                    <label for="male"><g:message code="user.gender" default="GENDER" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'gender', 'errors')}">
	                                <g:select from="${ConfigurationHolder.config.comics.gender}" name="gender" value="${userInstance?.gender}" valueMessagePrefix="gender"/>
                                </td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="email"><g:message code="user.email" default="EMAIL" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'email', 'errors')}">
                                    <g:textField name="email" value="${fieldValue(bean: userInstance, field: 'email')}" />
                                </td>
                                <td  valign="top" class="name">
                        			<label><g:message code="user.path" default="IMAGE PATH" />:</label></td>
                        		<td  valign="top" class="value ${hasErrors(bean: userInstance, field: 'path', 'errors')}">
                        			<input type="file" name="file"/>
                        		</td>
                            </tr>
                        
                            <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="password"><g:message code="user.password" default="PASSWORD" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'password', 'errors')}">
                                    <g:passwordField name="password" value="${fieldValue(bean: userInstance, field: 'password')}" />
                                </td>
                                <td valign="top" class="name">
                                    <label for="rateable"><g:message code="user.rateable" default="RATEABLE" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'rateable', 'errors')}">
                                    <g:checkBox name="rateable" value="${userInstance?.rateable}" />
                                </td>
                            </tr>
                        
	                        <tr class="prop">
                                <td valign="top" class="name">
                                    <label for="repeatPassword"><g:message code="user.repeatPassword" default="REPEAT PASSWORD" />:</label>
                               	</td>
                               	<td valign="top" class="value ${hasErrors(bean:userInstance,field:'password','errors')}">
		                            <g:passwordField name="repeatPassword" value="${fieldValue(bean:userInstance,field:'password')}"/>
		                        </td>
		                        <td valign="top" class="name">
                                    <label for="commentable"><g:message code="user.commentable" default="COMMENTABLE" />:</label>
                                </td>
                                <td valign="top" class="value ${hasErrors(bean: userInstance, field: 'commentable', 'errors')}">
                                    <g:checkBox name="commentable" value="${userInstance?.commentable}" />
                                </td>
                           	</tr>
                        </tbody>
                    </table>
                    <div class="buttons">
	                    <span class="button"><g:submitButton name="create" class="save" value="${message(code: 'create', 'default': 'CREATE')}" /></span>
	                </div>
                </div>
            </g:uploadForm>
    </body>
</html>
